package controlador;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import modelo.mIngrediente;
import modelo.mIngredienteDao;

import vista.VentaProductoCantidadASC;
import vista.vIngredientesDisponiblesMT;
import vista.vLIngredienteDis;

public class cLIngredienteDis implements ActionListener {

	private vLIngredienteDis  ingdis;

	public cLIngredienteDis() {
		super();
	
		this.ingdis= new vLIngredienteDis ();
		this.ingdis.setLocation(480,210);
		this.ingdis.setVisible(true);
		this.ingdis.addListener(this);
		cargarIngredientes();		
	}

	public void actionPerformed(ActionEvent e) {
		String actionCommand = e.getActionCommand();
	if(actionCommand.equals("Salir"))
	{
		this.ingdis.dispose();
	}
	if(actionCommand.equals("Ingredientes Disponibles")){
		cargarIngredientes();
	}
	}
	   private void cargarIngredientes()
	   {
		   mIngredienteDao ingredientedao = new mIngredienteDao();
			List<mIngrediente> ingredientes = ingredientedao.Consultar();
			this.ingdis.setResultados(new vIngredientesDisponiblesMT(ingredientes));
		}
}
